﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FundRaising.BLL;
using System.Collections;


namespace FundRaising.GUI
{
    public partial class EditRequest : System.Web.UI.Page
    {
        public static bool first = true;
        public static bool first2 = true;
        public static int j = 0;
        public static Guid RequestKey;
        public static CurrConv Curr = new CurrConv();  
        protected void Page_Load(object sender, EventArgs e)
        {
           if(first) fillprojddl();
           if (first2) fillDomainDDL();
        }


        public void fillprojddl()
        {

            RequestBLL bll = new RequestBLL();
            
            DAL._FR_DS_SmalParam.RequestDataTable AssoName;
            if (first) AssoName = bll.GetProjByAssoName(null);
            else AssoName = bll.GetProjByAssoName(AssoDDL.SelectedValue);

            ArrayList Name = new ArrayList();
            //Hashtable Name = new Hashtable();
            if(!first) Name.Add("");
            for (int i = 0; AssoName.Rows.Count > i; i++)
            {
                Name.Add(Convert.ToString(AssoName[i][0]));
            }
            DropDownList ddl = new DropDownList();
            ProjDDL.DataSource = Name;
            ProjDDL.DataTextField = null;
            ProjDDL.DataValueField = null;
            ProjDDL.DataBind();
           

        }

        public void fillDomainDDL()
        {

            RequestBLL bll = new RequestBLL();
            DAL._FR_DS_SmalParam.Request1DataTable FundName;
            if (first2) FundName = bll.getdata(null);
            else FundName = bll.getdata(FundDDL.SelectedValue);

            ArrayList Name = new ArrayList();
            //Hashtable Name = new Hashtable();
            if (!first2) Name.Add("");
            for (int i = 0; FundName.Rows.Count > i; i++)
            {
                Name.Add(Convert.ToString(FundName[i][0]));
            }
            DropDownList ddl = new DropDownList();
            DomainDDL.DataSource = Name;
            DomainDDL.DataTextField = null;
            DomainDDL.DataValueField = null;
            DomainDDL.DataBind();

        }
        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            GUI.EditRequest.j = 0;
            Response.Redirect("NewRequest.aspx");
        }

        protected void FundDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            string A = FundDDL.SelectedValue;
            if (FundDDL.SelectedValue == "")
                first2 = true;
             else first2 = false;
            fillDomainDDL();
        }

        protected void GridView2_SelectedIndexChanged1(object sender, EventArgs e)
        {


            DataKeyArray keyValues = GridView2.DataKeys;


            int a1 = GridView2.SelectedIndex;
            RequestKey = new Guid(keyValues[a1].Value.ToString());
        

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {

            
            string url = "Extensions/RequestEditing.aspx?ID=1&cat=test";
            string fullURL = "window.open('" + url + "', '_blank', 'height=400,width=840,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
        }

        protected void AssoDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (AssoDDL.SelectedValue == "")
                first = true;
            else first =false ;
            fillprojddl();
        }

        protected void ProjDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
                first = false;
        }

        protected void DomainDDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            first2 = false;
        }

        

        
    }
}
